<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="../vue.js"></script>
</head>

<body>
    <div id ="root">
        <h2>当前的n值是: <span v-text="n"></span>  </h2> 
        <h2>放大十倍的n值是: <span v-big="n"></span>  </h2> 
        <button @click="n++">点我n+1</button>
        <hr>
        <input type="text" v-fbind:value="n">
    </div>

    <script>
     //创建Vue实例,得到 ViewModel
     var vm = new Vue({
        el: '#root',
        data: {
            n:1
        },
        directives:{
            big(element,binding){
                element.innerText = binding.value * 10    
            },
            fbind(element, binding){
                element.value = binding.value
            }
        },
        methods: {

        }
     });
    </script>
</body>

</html>